#!/usr/bin/python3
#! -*- coding:utf-8 -*-

import random


class Node:
    def __init__(self, item):
        self.item = item
        self.next = None


def create_link_head(ls):
    head = Node(ls[0])
    for el in ls[1:]:
        node = Node(el)
        node.next = head
        head = node
    return head


def create_link_tail(ls):
    head = Node(ls[0])
    tail = head
    for el in ls[1:]:
        node = Node(el)
        tail.next = node
        tail = node
    return head


def print_linklist(lk):
    while lk:
        print(lk.item, end=', ')
        lk = lk.next
    print()


lst = sorted([random.randint(-100, 100) for _ in range(10)])

lkt1 = create_link_head(lst)
print_linklist(lkt1)

lkt2 = create_link_tail(lst)
print_linklist(lkt2)

